-
Notifications
You must be signed in to change notification settings - Fork 93
feat: add type safety for builder configurations with discriminated unions #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 9c754af The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
e832c5b to
9290a95
Compare
bff8430 to
21d8ce1
Compare
21d8ce1 to
87c62d3
Compare
9290a95 to
1e73424
Compare
|
@copilot Can you try to fix the build error?
|
|
@TooTallNate I've opened a new pull request, #200, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The WorkflowConfig type is missing the SvelteKitConfig interface, causing TypeScript to reject buildTarget: 'sveltekit' in the SvelteKit builder. While 'sveltekit' is included in the validBuildTargets array, there's no corresponding interface in the discriminated union.
View Details
📝 Patch Details
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
Analysis
Missing SvelteKit configuration interface causes TypeScript compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts:25:7 due to missing SvelteKitConfig interface in the WorkflowConfig union type
How to reproduce:
cd packages/sveltekit && pnpm run buildResult:
src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The WorkflowConfig discriminated union type is missing SvelteKitConfig, causing TypeScript to reject buildTarget: 'sveltekit' assignments. The validBuildTargets array includes 'sveltekit' but the corresponding interface and union type member were not defined.
View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
StandaloneConfig,
VercelBuildOutputConfig,
NextConfig,
+ SvelteKitConfig,
} from './types.js';
export { validBuildTargets, isValidBuildTarget } from './types.js';
export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
Analysis
Missing SvelteKitConfig type causes TypeScript compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts:25:7 due to missing SvelteKitConfig interface in the WorkflowConfig discriminated union
How to reproduce:
cd packages/sveltekit && pnpm run buildResult:
src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The WorkflowConfig union type was missing a SvelteKitConfig interface, causing TypeScript to reject the buildTarget: 'sveltekit' assignment in the SvelteKit builder constructor.
View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
StandaloneConfig,
VercelBuildOutputConfig,
NextConfig,
+ SvelteKitConfig,
} from './types.js';
export { validBuildTargets, isValidBuildTarget } from './types.js';
export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
diff --git a/packages/sveltekit/src/builder.ts b/packages/sveltekit/src/builder.ts
index 90409d3..3427c4e 100644
--- a/packages/sveltekit/src/builder.ts
+++ b/packages/sveltekit/src/builder.ts
@@ -1,7 +1,7 @@
import { constants } from 'node:fs';
import { access, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
-import { BaseBuilder, type WorkflowConfig } from '@workflow/builders';
+import { BaseBuilder, type SvelteKitConfig } from '@workflow/builders';
// Helper function code for converting SvelteKit requests to standard Request objects
const SVELTEKIT_REQUEST_CONVERTER = `
@@ -18,15 +18,15 @@ async function convertSvelteKitRequest(request) {
`;
export class SvelteKitBuilder extends BaseBuilder {
- constructor(config?: Partial<WorkflowConfig>) {
+ constructor(config?: Partial<SvelteKitConfig>) {
super({
- ...config,
dirs: ['workflows'],
buildTarget: 'sveltekit' as const,
stepsBundlePath: '', // unused in base
workflowsBundlePath: '', // unused in base
webhookBundlePath: '', // unused in base
- workingDir: config?.workingDir || process.cwd(),
+ workingDir: process.cwd(),
+ ...config,
});
}
Analysis
Missing SvelteKitConfig in TypeScript union type causes compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in WorkflowConfig union type
How to reproduce:
cd packages/sveltekit && pnpm buildResult:
src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The WorkflowConfig discriminated union was missing a SvelteKitConfig interface, causing TypeScript to reject the 'sveltekit' build target as an invalid type.
View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
StandaloneConfig,
VercelBuildOutputConfig,
NextConfig,
+ SvelteKitConfig,
} from './types.js';
export { validBuildTargets, isValidBuildTarget } from './types.js';
export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
Analysis
Missing SvelteKitConfig type causes TypeScript compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts due to missing SvelteKitConfig interface in the WorkflowConfig discriminated union
How to reproduce:
pnpm turbo build --filter='@workflow/sveltekit'Result:
src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The WorkflowConfig union type was missing the SvelteKitConfig interface, even though 'sveltekit' was included in the validBuildTargets array, causing a TypeScript error when trying to use buildTarget: 'sveltekit' in the SvelteKit builder.
View Details
📝 Patch Details
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
Analysis
Missing SvelteKitConfig interface causes TypeScript compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in the WorkflowConfig union type
How to reproduce:
cd packages/sveltekit && pnpm run buildResult:
src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The WorkflowConfig type union is missing the SvelteKitConfig interface, even though 'sveltekit' was added as a valid build target. This causes TypeScript to reject buildTarget: 'sveltekit' in the SvelteKit builder.
View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
StandaloneConfig,
VercelBuildOutputConfig,
NextConfig,
+ SvelteKitConfig,
} from './types.js';
export { validBuildTargets, isValidBuildTarget } from './types.js';
export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
Analysis
Missing SvelteKitConfig type causes TypeScript compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in the WorkflowConfig union type
How to reproduce:
cd packages/sveltekit && pnpm run buildResult:
src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The validBuildTargets array includes 'sveltekit' but the WorkflowConfig type union was missing the corresponding SvelteKitConfig interface, causing TypeScript to reject 'sveltekit' as a valid buildTarget value.
View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
StandaloneConfig,
VercelBuildOutputConfig,
NextConfig,
+ SvelteKitConfig,
} from './types.js';
export { validBuildTargets, isValidBuildTarget } from './types.js';
export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
diff --git a/packages/sveltekit/src/builder.ts b/packages/sveltekit/src/builder.ts
index 90409d3..c49fa67 100644
--- a/packages/sveltekit/src/builder.ts
+++ b/packages/sveltekit/src/builder.ts
@@ -1,7 +1,7 @@
import { constants } from 'node:fs';
import { access, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
-import { BaseBuilder, type WorkflowConfig } from '@workflow/builders';
+import { BaseBuilder, type SvelteKitConfig } from '@workflow/builders';
// Helper function code for converting SvelteKit requests to standard Request objects
const SVELTEKIT_REQUEST_CONVERTER = `
@@ -18,7 +18,7 @@ async function convertSvelteKitRequest(request) {
`;
export class SvelteKitBuilder extends BaseBuilder {
- constructor(config?: Partial<WorkflowConfig>) {
+ constructor(config?: Partial<SvelteKitConfig>) {
super({
...config,
dirs: ['workflows'],
Analysis
Missing SvelteKitConfig interface causes TypeScript compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in the builders package type system
How to reproduce:
cd packages/sveltekit && npx tsc --noEmit --skipLibCheck src/builder.tsResult:
src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The WorkflowConfig union type is missing the SvelteKitConfig interface, causing TypeScript to reject buildTarget: 'sveltekit' assignments even though 'sveltekit' is a valid build target.
View Details
📝 Patch Details
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
webhookBundlePath: string;
}
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+ buildTarget: 'sveltekit';
+ // SvelteKit builder computes paths dynamically, so these are not used
+ stepsBundlePath: string;
+ workflowsBundlePath: string;
+ webhookBundlePath: string;
+}
+
/**
* Discriminated union of all builder configuration types.
*/
export type WorkflowConfig =
| StandaloneConfig
| VercelBuildOutputConfig
- | NextConfig;
+ | NextConfig
+ | SvelteKitConfig;
export function isValidBuildTarget(
target: string | undefined
Analysis
Missing SvelteKitConfig interface causes TypeScript compilation failure
What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts:25 due to missing SvelteKitConfig interface in the WorkflowConfig union type
How to reproduce:
pnpm turbo build --filter=@workflow/sveltekitResult:
[ERROR] @workflow/sveltekit:build: src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.
[ERROR] @workflow/sveltekit:build: ELIFECYCLE Command failed with exit code 2.Signed-off-by: Nathan Rajlich <[email protected]>

Improves type safety by creating discriminated union types for builder-specific
configurations, making it clear which configuration options are required for
each builder type.
Changes:
This enables better IntelliSense and type checking when constructing builder
configurations, preventing invalid configuration combinations at compile time.
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]